package com.task.common.handler;

import java.net.URISyntaxException;

import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;

/**
 * The module containing all dependencies required by the {@link Handler}.
 */
public class DependencyFactory {

  private DependencyFactory() {
  }

  /**
   * @return an instance of S3Client
   */
  public static S3Client s3Client() throws URISyntaxException {
    StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
        AwsBasicCredentials.create("AKIAVZTEXJQYZBOM4X3U", "RNP1DK8p5cw1Rm+GXKBkHWUbE51CwDP5Vqy+8jT4"));
    return S3Client.builder()
        //.credentialsProvider(DefaultCredentialsProvider.create())
        .credentialsProvider(credentialsProvider)
        .region(Region.US_EAST_1)
        .httpClientBuilder(ApacheHttpClient.builder())
        //.endpointOverride(new URI("https://dw4acmyrvk23a.cloudfront.net"))
        //.endpointOverride(URI.create("https://dw4acmyrvk23a.cloudfront.net"))
        //.forcePathStyle(true)
        .build();
  }
}